eclipse.runtime.include("../log/log.eclipse.js");
log.switchover(false);
eclipse.runtime.include("../run/run.eclipse.js");
log.log('include test');

/**
 * 单元测试
 * 
 * @param {String}
 *            filePath
 */
var Test = function(filePath) {
	this.file = new File(filePath);
	this.run = new Run(filePath);
};
/**
 * 测试是否通过
 * 
 * @return {Boolean}
 */
Test.prototype.test = function() {
	var text = this.file.getContent(), format = this.run.run();
	var minText = this.compress(text), minFormat = this.compress(format);
	if (minText != undefined && minText == minFormat) {
		return true;
	} else {
		this.log = 'orignal:    ' + minText;
		this.log += '\r\n';
		this.log += 'format :    ' + minFormat;
		return false;
	}
};
/**
 * 压缩字符串
 * 
 * @param {String}
 *            str
 */
// Test.prototype.compress = function(str) {
// return str && str.replace(/\s+/g, '').replace(/\r/g, '').replace(/\n/g, '');
// };
// var filePath = 'D:/documents and
// settings/wuqinglong/git/JspFormat/src/test/test.txt';
// filePath = 'C:/Users/wql/git/JspFormat/src/test/test.txt';
// var test = new Test(filePath), flag = test.test();
log.switchover(true);
// log.log('-------------------start test 01--------------------');
// log.log('format file ' + ( flag ? 'success' : 'failure') + ' !');
// log.log('file = ' + filePath);
// if (!flag) {
// log.log(test.log);
// }
// log.log('--------------------end test 01---------------------');
/*
 * log.log('------------------start test 02---------------------'); var etag=new
 * ETag('div','<div id="dev_div" style="width:100px;height:100px;">',null,'</div>');
 * var childEtag0=new ETag('p','<p id="dev_p" style="width:100px;height:100px;">','this
 * is P!','</p>'); var childEtag1=new ETag('span','<span id="dev_span"
 * style="width:100px;height:100px;">',null,'</span>'); var childEtag2=new
 * ETag('span','<span id="dev_span2" style="width:100px;height:100px;">','this
 * is another span!','</span>'); var imgEtag=new ETag('img',null,'<img src=""
 * alt="" title="" />',null); childEtag1.setBody([imgEtag,childEtag0,imgEtag]);
 * //etag.setBody([childEtag1]);
 * etag.setBody([childEtag0,childEtag1,childEtag2]); var format=new Format();
 * log.log(format.format([etag,etag])); log.log('--------------------end test
 * 02---------------------');
 */
var time1 = new Date().getTime();
var text = new Run().run({
	// 缩进字符
	tabStr : '  ',
	// 是否调试
	debug : true,
	// 单行最小宽度
	lineMinWidth : 80,
	noFormat : false
});
var time2 = new Date().getTime();
log.switchover(true);
log.log('------------------start test  03---------------------');
log.log(text);
log.log('------------------time is ' + (time2 - time1) + 'ms-------');
log.log('------------------end test  03-----------------------');
